package cn.sytton.taffe.job.entity;

import cn.sytton.taffe.framework.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;

/**
 * 定时任务日志entity sys_job
 *
 * @author skyrock
 */
@Schema(description = "定时任务执行日志")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("sys_job_log")
public class JobLogEntity extends BaseEntity {

    @Schema(description = "任务执行日志")
    @TableId(type = IdType.ASSIGN_ID)
    private String logId;         //日志ID

    @Schema(description = "任务名称")
    private String jobName;          // 任务名称

    @Schema(description = "任务组名")
    private String jobGroup;         // 任务组名

    @Schema(description = "调用目标字符串")
    private String invokeTarget;     // 调用目标字符串

    @Schema(description = "执行时间")
    private long runningTime;     // 执行时间

    @Schema(description = "异常信息")
    private String exceptionMessage; // 异常信息

    @Schema(description = "状态（1成功 0失败）")
    private Integer status =  1;     // 状态（1成功 0失败）

    @Schema(description = "开始执行时间")
    @JsonFormat
    private Timestamp startTime;     // 开始执行时间

    @Schema(description = "结束执行时间")
    @JsonFormat
    private Timestamp stopTime;      // 结束执行时间

    //-----以下是关联属性-----

    @Schema(description = "查询开始执行时间")
    @JsonFormat
    @TableField(exist = false)
    private Timestamp queryBeginTime;     // 查询字段 startTime >= beginTime

    @Schema(description = "查询结束执行时间")
    @JsonFormat
    @TableField(exist = false)
    private Timestamp queryEndTime;       // 查询字段 startTime <= endTime
}
